package com.ccsoft.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 动态代理 - 代理类
 */
public class DynamicProxy implements InvocationHandler {
    private Object provider;

    public DynamicProxy(Object provider) {
        this.provider = provider;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("dynamic proxy before invoke [" + method.getName() + "]");
        Object result = method.invoke(provider,args);
        System.out.println("dynamic proxy after invoke [" + method.getName()+"]");
        return result;
    }
}
